package org.example.loadbalancer;

import org.example.spi.SpiLoader;

/**
 * @Description: TODO
 * @Author: sats@jz
 * @Date: 2025/1/13 16:58
 **/
public class LoadBalancerFactory {
    static {
        SpiLoader.load(LoadBalancer.class);
    }


    private static final LoadBalancer DEFAULT_LOAD_BALANCER  = new RoundRobinLoadBalancer();


    public static LoadBalancer getLoadBalancer(String loadBalancerName) {
        LoadBalancer loadBalancer = SpiLoader.getInstance(LoadBalancer.class, loadBalancerName);
        return loadBalancer == null ? DEFAULT_LOAD_BALANCER : loadBalancer;
    }
}
